(define-module (rain mame)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (guix utils)
  #:use-module (guix packages)
  #:use-module (guix download)
  #:use-module (guix git-download)
  #:use-module (guix svn-download)
  #:use-module (gnu packages)
  #:use-module (gnu packages algebra)
  #:use-module (gnu packages autotools)
  #:use-module (gnu packages backup)
  #:use-module (gnu packages base)
  #:use-module (gnu packages admin)
  #:use-module (gnu packages audio)
  #:use-module (gnu packages avahi)
  #:use-module (gnu packages boost)
  #:use-module (gnu packages fribidi)
  #:use-module (gnu packages game-development)
  #:use-module (gnu packages gettext)
  #:use-module (gnu packages gl)
  #:use-module (gnu packages glib)
  #:use-module (gnu packages gnome)
  #:use-module (gnu packages gtk)
  #:use-module (gnu packages guile)
  #:use-module (gnu packages libcanberra)
  #:use-module (gnu packages libunwind)
  #:use-module (gnu packages haskell)
  #:use-module (gnu packages mp3)
  #:use-module (gnu packages image)
  #:use-module (gnu packages ncurses)
  #:use-module (gnu packages python)
  #:use-module (gnu packages readline)
  #:use-module (gnu packages xorg)
  #:use-module (gnu packages pkg-config)
  #:use-module (gnu packages databases)
  #:use-module (gnu packages sdl)
  #:use-module (gnu packages texinfo)
  #:use-module (gnu packages check)
  #:use-module (gnu packages fonts)
  #:use-module (gnu packages fontutils)
  #:use-module (gnu packages gstreamer)
  #:use-module (gnu packages bash)
  #:use-module (gnu packages perl)
  #:use-module (gnu packages qt)
  #:use-module (gnu packages compression)
  #:use-module (gnu packages pulseaudio)
  #:use-module (gnu packages linux)
  #:use-module (gnu packages zip)
  #:use-module (gnu packages xiph)
  #:use-module (gnu packages curl)
  #:use-module (gnu packages lua)
  #:use-module (gnu packages video)
  #:use-module (gnu packages xml)
  #:use-module (gnu packages tcl)
  #:use-module (gnu packages fribidi)
  #:use-module (guix build-system trivial)
  #:use-module (guix build-system gnu)
  #:use-module (guix build-system haskell)
  #:use-module (guix build-system cmake)
  #:use-module (guix build-system trivial))

(define-public mame
  (package
    (name "mame")
    (version "171")
    (source
     (origin
       (method url-fetch)
       (uri (string-append "https://github.com/mamedev/mame/archive/mame0"
                           version ".tar.gz"))
       (sha256
        (base32
         "1ib32w977g5465yfn39pr15pbhxaxaiisvnyz20aw0lb4dp32hz5"))))
    (build-system gnu-build-system)
    (arguments
     `(#:make-flags
       (list "USE_QTDEBUG=0")
       #:tests? #f
       #:phases
       (modify-phases %standard-phases
         (delete 'configure)
         (replace 'install
           (lambda* (#:key source #:allow-other-keys)
             (mkdir-p (string-append %output "/bin"))
             (copy-file "mame64" (string-append %output "/bin/mame64")))))))
    (inputs `(("glib" ,glib)
              ("libxinerama" ,libxinerama)
              ("alsa-lib" ,alsa-lib)
              ("sdl" ,(sdl-union (list sdl2 sdl2-ttf)))
              ("expat" ,expat)
              ("fontconfig" ,fontconfig)
              ("glu" ,glu)
              ("gtkglext" ,gtkglext)))
    (native-inputs `(("python-2" ,python-2)
                     ("pkg-config" ,pkg-config)))
    (home-page "http://mamedev.org/")
    (synopsis "Multiple Arcade Machine Emulator.")
    (description "MAME's purpose is to preserve decades of software history. As electronic technology continues to rush forward, MAME prevents this important \"vintage\" software from being lost and forgotten. This is achieved by documenting the hardware and how it functions. The source code to MAME serves as this documentation")
    (license license:gpl2+)))
